<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'/>
    <title>模板文件上传</title>
    <%@include file="/WEB-INF/pages/common/taglib.jsp" %>
    <%@include file="/WEB-INF/pages/common/common.jsp" %>
    <script type="text/javascript" src="${basePath}/js/bootstrap/bootstrap.min.js"></script>
    <script>
        var fileObj, fileExt, hasChecked;
        /*以下为限制变量*/
        var AllowExt = ".xls,.xlsx";
        function CheckExt(address) {
            if (address == "") {
                $('#warnMessage').html("请上传有效模板文件");
                document.all.uploadButton.disabled = true;
                return false;
            }
            fileObj = address;
            $('#warnMessage').html("");
            document.all.uploadButton.disabled = false;
            fileExt = address.substr(address.lastIndexOf(".")).toLowerCase();
            if (AllowExt != 0 && AllowExt.indexOf(fileExt) == -1) {
                $('#warnMessage').html("当前文件类型为" + fileExt + ",请上传" + AllowExt + "类型的文件!");
                document.all.uploadButton.disabled = true;
                return false;
            }
            $("input[name='key']").val(parent.$("input[name='key']").val());
            $("input[name='className']").val(parent.$("input[name='className']").val());
            $("input[name='type']").val(parent.$("input[name='type']").val());
            return true;
        }
        $(function () {
//            window.setTimeout(function () {
//                parent.$("#btnSearch").click();
//            }, 1000);

            if (${'OK' == msg}) {

                showOKMessage('文件上传成功', '系统提示', function () {
//                    parent.location.reload();
                    parent.$("#btnSearch").click();
                    parent.layer.closeAll();
                });
            } else {
                $('#warnMessage').html("${msg}");
            }
        });
    </script>
</head>
<body>
<form id="form" action="${basePath}/uploadfile/doTemplateUpload" enctype="multipart/form-data" method="post">
    <div class="content">
        <input type="hidden" name="type"/>
        <input type="hidden" name="key"/>
        <input type="hidden" name="pages"/>
        <input type="hidden" name="className"/>
        <table class="table3">
            <tr>
                <th><strong>提示</strong> 上传的文件请以平台提供的模板文件为蓝本，目前只支持导入xls或者是xlsx格式的文件.</th>
            </tr>
            <tr>
                <td>
                    <label>
                        <input type="file" class="input1" style="width:100%" name="file" onchange="CheckExt(value)"/>
                    </label>
                </td>
            </tr>
        </table>
        <div style="text-align: center;margin-top: 10px">
            <input style="padding: 5px 10px;" id="uploadButton" disabled type="submit" value="导&nbsp;&nbsp;入"/>
            <input style="padding: 5px 10px;margin-left: 20px" type="button" onclick="cancel();"
                   value="取&nbsp;&nbsp;消"/>
        </div>
        <div id="warnMessage" style='color: red'>
        </div>
    </div>
</form>
<script>
    function cancel() {
        parent.layer.close(parent.layer.getFrameIndex(window.name)); //执行关闭
    }
</script>
</body>
</html>
